﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MesErreurs;
using Metier;


namespace Gestion_commerciale
{
    public partial class FClient : Form
    {
        public FClient()
        {
            InitializeComponent();
            List<String> mesNumeros;
            try
            {
                // Lecture classique
                Clientel unClient = new Clientel();
                mesNumeros = unClient.LectureNoClient();
                foreach (String item in mesNumeros)
                {
                    cb_Client.Items.Add(item);
                }
            }
            catch (MonException exception)
            {
                MessageBox.Show(exception.MessageApplication(), exception.Message);
            }
        }

        private void bt_Interroger_Click(object sender, EventArgs e)
        {
            string numCli;
            Clientel unClient = new Clientel();
            Clientel unClientCherche;

            try
            {
                numCli = cb_Client.Text;
                unClientCherche = unClient.RechercheUnClient(numCli);
                lb_Nom.Text = "Nom : " + unClientCherche.NomCl;
                lb_Prenom.Text = "Prénom : " + unClientCherche.PrenomCl;
                lb_Societe.Text = "Societe : " + unClientCherche.Societe;
                lb_Adresse.Text = "Adresse : " + unClientCherche.AdresseCl;
                lb_Ville.Text = "Ville : " + unClientCherche.VilleCl;
                lb_Cp.Text = "Code Postal : " + unClientCherche.CodePostCl;

            }
            catch (MonException exception)
            {
                MessageBox.Show(exception.MessageApplication(), exception.Message);
            }
        }
    }
}

